package com.sc.nft.entity.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import com.sc.nft.entity.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class GetGiveMetaWalleFeeVO {

    @ApiModelProperty("需要数量")
    private String requiredNumber;

    @ApiModelProperty("拥有的数量")
    private String quantityOwned;

    @ApiModelProperty(value = "消耗类型 1.星球碎片 2.余额 3.生态燃料")
    private Integer consumeType;




    public void userBalance(UserWallet userWallet) {
        if (BeanUtil.isNotEmpty(userWallet)) {
            this.quantityOwned=userWallet.getBalance().add(userWallet.getPayBalance().setScale(2, BigDecimal.ROUND_DOWN)).toPlainString();
        }
    }

    public void userDebris(UserAssets userAssets) {
        if (BeanUtil.isNotEmpty(userAssets)) {
            this.quantityOwned=userAssets.getTokenNum().setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }else {
            this.quantityOwned=BigDecimal.ZERO.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }
    }

    public void userEcology(UserEcologyPoints userEcologyPoints) {
        if (BeanUtil.isNotEmpty(userEcologyPoints)) {
            this.quantityOwned=userEcologyPoints.getAmount().setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }else {
            this.quantityOwned=BigDecimal.ZERO.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
        }
    }


    public void calculate(CollectionGift collectionGift, Integer sum) {
        this.requiredNumber = Convert.toBigDecimal(sum).multiply(Convert.toBigDecimal(collectionGift.getQuantityConsume()).setScale(2,BigDecimal.ROUND_DOWN)).toPlainString();
        this.consumeType=collectionGift.getConsumeType();
    }
}
